package com.chl.io.inputstream;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;

import javax.imageio.ImageIO;

public class ImageIo {

	public static void main(String[] args) {
		
		String[] formats = ImageIO.getReaderFormatNames();
		System.out.println("支持的格式：" + Arrays.toString(formats));
		
		testImg();
	}
	
	
	static void testUrl() {
		String imgUrl = "https://file.test.ewt360.com/api/fileService/file/2050244823914570316";
		BufferedImage img = null;
		try (InputStream is = new URL(imgUrl).openStream()) {
			img = ImageIO.read(is);
			System.out.println(img);
		} catch (Exception e) {
			System.out.println(img);
		}
	}
	
	
	static void testImg(){
		File input = new File("C:\\Users\\006006\\Desktop\\2050206710374785211.png");
		try {
			BufferedImage img = ImageIO.read(input);
			System.out.println(img);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
